package com.example.product.RocketMq;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class MQProductProducer {
    private static final String topic = "PRODUCT_TOPIC";
    @Value("${rocketmq.producer.send-message-timeout}")
    private Integer messageTimeOut;
    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void sendOneWayMsg(String key) {
        rocketMQTemplate.sendOneWay(topic, MessageBuilder.withPayload(key).build());
    }
}
